package com.msmall.community.wish.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.msmall.base.model.BaseObject;
import com.msmall.base.util.Constants;
import com.msmall.community.common.util.WishUtil;

/**
 * 心愿类型
 */
@Entity
@Table(name = "wish_type")
public class WishType extends BaseObject {

	private static final long serialVersionUID = -6709153398315656643L;

	@Id
	@Column(name = "typeid", insertable = false, updatable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long typeid;
	
	/**
	 * 名称
	 */
	@Column(name = "name")
	private String name;
	
	@Column(name = "description")
	private String description;
	
	/**
	 * 背景图片地址，相对地址
	 */
	@Column(name = "bg_img")
	private String bgImg;
	/**
	 * 背景图片名称
	 */
	@Column(name = "bg_img_name")
	private String bgImgName;
	
	/**
	 * commonImg activeImg的图片大小，最好是正方形，如果是长方形，写入长；单位px
	 */
	@Column(name = "imgSize")
	private Integer imgSize;
	/**
	 * 未激活的心愿图片地址，相对地址
	 */
	@Column(name = "common_img")
	private String commonImg;
	/**
	 * 未激活的心愿图片名称
	 */
	@Column(name = "common_img_name")
	private String commonImgName;
	
	/**
	 * 激活的心愿图片地址，相对地址
	 */
	@Column(name = "active_img")
	private String activeImg;
	/**
	 * 激活的心愿图片名称
	 */
	@Column(name = "active_img_name")
	private String activeImgName;
	/**
	 * 此类心愿的最少字数
	 */
	@Column(name = "chars_min")
	private Integer charsMin;
	
	/**
	 * 此类心愿的最长字数
	 */
	@Column(name = "chars_max")
	private Integer charsMax;
	
	/**
	 * 此类心愿每个页面显示多少个心愿
	 */
	@Column(name = "threshold")
	private Integer threshold;
	
	/**
	 * 此类心愿可以许愿多少个,<0不做限制
	 */
	@Column(name = "capacity")
	private Long capacity;
	
	/**
	 * 历史愿望总算
	 */
	@Column(name = "total_amount")
	private Long totalAmount;
	/**
	 * 当前激活的数量
	 */
	@Column(name = "activity_amount")
	private Long activityAmount;
	
	/**
	 * 每个心愿所代表的图片相对背景图片的位置,严格格式，必填<br/>
	 * 格式：x1,y1;x2,y2;x3,y3(x,y最多为4位数字)
	 */
	@Column(length=10000, name="position")
	private String position;
	
	/**
	 * position的位置数量
	 */
	@Column(name="position_amount")
	private Integer positionAmount;
	
	@Column(name = "enabled")
	private Short enabled;
	
	@Column(name="create_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;

	@OneToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.LAZY, mappedBy="type")
	private Set<Wish> wishes;
	
	public Long getTypeid() {
		return typeid;
	}

	public void setTypeid(Long typeid) {
		this.typeid = typeid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getBgImg() {
		return bgImg;
	}

	public void setBgImg(String bgImg) {
		this.bgImg = bgImg;
	}

	public Integer getImgSize() {
		return imgSize;
	}

	public void setImgSize(Integer imgSize) {
		this.imgSize = imgSize;
	}

	public String getCommonImg() {
		return commonImg;
	}

	public void setCommonImg(String commonImg) {
		this.commonImg = commonImg;
	}

	public String getBgImgName() {
		return bgImgName;
	}

	public void setBgImgName(String bgImgName) {
		this.bgImgName = bgImgName;
	}

	public String getCommonImgName() {
		return commonImgName;
	}

	public void setCommonImgName(String commonImgName) {
		this.commonImgName = commonImgName;
	}

	public String getActiveImgName() {
		return activeImgName;
	}

	public void setActiveImgName(String activeImgName) {
		this.activeImgName = activeImgName;
	}

	public String getActiveImg() {
		return activeImg;
	}

	public void setActiveImg(String activeImg) {
		this.activeImg = activeImg;
	}

	public Integer getCharsMin() {
		return charsMin;
	}

	public void setCharsMin(Integer charsMin) {
		this.charsMin = charsMin;
	}

	public Integer getCharsMax() {
		return charsMax;
	}

	public void setCharsMax(Integer charsMax) {
		this.charsMax = charsMax;
	}

	public Integer getThreshold() {
		return threshold;
	}

	public void setThreshold(Integer threshold) {
		this.threshold = threshold;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Integer getPositionAmount() {
		return positionAmount;
	}

	public void setPositionAmount(Integer positionAmount) {
		this.positionAmount = positionAmount;
	}

	public Long getCapacity() {
		return capacity;
	}

	public void setCapacity(Long capacity) {
		this.capacity = capacity;
	}

	public Long getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Long totalAmount) {
		this.totalAmount = totalAmount;
	}

	public Long getActivityAmount() {
		return activityAmount;
	}

	public void setActivityAmount(Long activityAmount) {
		this.activityAmount = activityAmount;
	}

	public Short getEnabled() {
		return enabled;
	}

	public void setEnabled(Short enabled) {
		this.enabled = enabled;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Set<Wish> getWishes() {
		return wishes;
	}

	public void setWishes(Set<Wish> wishes) {
		this.wishes = wishes;
	}

	public String getHtmlBgImg(){
		return WishUtil.getHomePath(typeid, Constants.USER_AGENT_TYPE_HTML) + bgImgName;
	}
	public String getHtmlCommonImg(){
		return WishUtil.getHomePath(typeid, Constants.USER_AGENT_TYPE_HTML) + commonImgName;
	}
	public String getHtmlActiveImg(){
		return WishUtil.getHomePath(typeid, Constants.USER_AGENT_TYPE_HTML) + activeImgName;
	}
	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}

}
